<?php
/**
 * <https://y.st./>
 * Copyright © 2019 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'Moving underground for a while',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<img src="/img/CC_BY-SA_4.0/y.st./weblog/2019/07/19.jpg" alt="Traffic" class="framed-centred-image" width="800" height="480"/>
<section id="diet">
	<h2>Dietary intake</h2>
	<p>
		For breakfast, I had a bowel of cereal.
		For lunch, I had a soft taco.
		I brought two more to work to have for dinner, but ended up eating only one of them.
	</p>
</section>
<section id="drudgery">
	<h2>Drudgery</h2>
	<p>
		My discussion post for the day:
	</p>
	<blockquote>
		<h3>Event handlers</h3>
		<p>
			Event handlers are typically functions that are called when a particular type of thing occurs in a program.
			In JavaScript, they&apos;re not exactly functions, but small snippets of code embedded in the $a[XHTML] as one of an element&apos;s attributes (W3Schools, n.d.).
			These snippets could of course call a function that does all the heavy lifting, the the event handler itself is not the function, but the snippet that contains the function call.
			There are some event handlers that seem like they shouldn&apos;t be bound to a specific element because they don&apos;t relate directly to any element, such as <code>onkeypress</code>, but you&apos;ve got to bind then to an element anyway (W3Schools, n.d.).
			To use the <code>onkeypress</code> event handler, you&apos;d bind it to some element such as the body like so: <code>&lt;body onkeypress=&quot;my_function()&quot;/&gt;</code>.
			Your <code>&lt;body/&gt;</code> element would obviously contain other elements, and thus wouldn&apos;t be self-terminating like the one shown here, but you get the point.
		</p>
		<h3>Callbacks</h3>
		<p>
			Callbacks are user-defined functions that get called by the main system or by a library when some predefined state occurs.
			Because they&apos;re user-defined, the system or library can&apos;t automatically know about a callback, so callbacks must be registered.
			They can also be passed to functions to be called by the receiving function on partly-processed data derived from from the other function arguments.
			In this case, they don&apos;t need to be registered, but instead are known because they&apos;re passed as arguments when they&apos;re needed.
		</p>
		<h3>Registering a callback</h3>
		<p>
			In JavaScript, registering a callback is done by passing the function object as an argument to a registration function.
			The main callback we&apos;ve been registering is <code>animate()</code>, which we register to set the scene for the next frame to be rendered.
		</p>
		<h3>Main event loop</h3>
		<p>
			Computers are able to wait for certain hardware events via the interrupt system.
			However, aside from that, computers don&apos;t know how to wait.
			They can&apos;t simply be instructed to run a program indefinitely either, at least not directly.
			Instead, they fallow the instructions given to them, and try to complete their task to terminate it.
			The usual way of of getting software to just keep running it to put it in a loop that doesn&apos;t terminate until you want the software to stop.
			This loop is the main event loop.
			Within the main event loop, you can check the state of the program, have branching logic, and even implement sub-loops.
			Basically, all your setup comes before the main event loop, all your clean-up-before-closing logic comes after the main event loop, and everything you need to happen repeatedly or continuously happens within the main event loop.
		</p>
		<p>
			In the assignments we&apos;ve been completing these past few weeks, the main event loop isn&apos;t even actually a loop structure, as defined as far as the programming-related meaning of a loop.
			Instead, we defined a function called <code>animate()</code>, which passes itself as an argument to <code>requestAnimationFrame()</code>.
			This registers <code>animate()</code> as a callback to be used when <code>three.js</code> needs the next frame and tells <code>three.js</code> that there&apos;s a next frame to request, but then when called, it registers itself for the next frame too.
			This causes control to be passed back and forth between these two, forming the main event loop.
		</p>
		<div class="APA_references">
			<h3>References:</h3>
			<p>
				W3Schools.
				(n.d.).
				<a href="https://www.w3schools.com/js/js_events.asp">JavaScript Events</a>.
				Retrieved from <code>https://www.w3schools.com/js/js_events.asp</code>
			</p>
			<p>
				W3Schools.
				(n.d.).
				<a href="https://www.w3schools.com/jsref/event_onkeypress.asp">onkeypress Event</a>.
				Retrieved from <code>https://www.w3schools.com/jsref/event_onkeypress.asp</code>
			</p>
		</div>
	</blockquote>
</section>
<section id="Minetest">
	<h2>Minetest</h2>
	<img src="/img/CC_BY-SA_3.0/minetest.net./weblog/2019/07/19.png" alt="A last look at my cabin on Sleepless Isle before I head under" class="framed-centred-image" width="1024" height="600"/>
	<p>
		I figured out what to do with my hundreds and hundreds of mushrooms.
		Use them as furnace fuel!
		I figured they probably wouldn&apos;t provide much smelting power, but they should provide <strong>*some*</strong>, just like leaves do, which would save me a few logs, right?
		It turns out they don&apos;t burn though.
		Darn.
	</p>
	<p>
		I took a break from building the bridge out to Restless Isle, and went mining again.
		I was pretty close to an iron level-up, so I wanted to get that taken care of.
		Besides, I needed a break from chopping down countless trees.
		I found my way to a huge cavern, and had to work my way along the ceiling to reach a wall before I could actually get down to the floor, as it&apos;s right under where I was digging.
		Getting down here is expensive though, in terms of inventory space.
		As I mentioned before, I never built the infrastructure to get me in and out of the mineshaft, such as stairs or ladders.
		This made it much faster to dig down deeper where I&apos;m hoping to find mese.
		However, as a trade-off, I have to stack things to get out, then mine away my stack to get back down.
		I&apos;ve been using quick-to-dig pine needles as my stacking node, so getting back down is fairly quick, but I still end up with an inventory half full of pine needles by the time I&apos;m down there, which in addition to other basic essentials I carry, such as picks and snow (for handling lava), makes it so I have to surface again pretty quickly to dump off what I&apos;ve gathered.
	</p>
	<p>
		This cavern&apos;s pretty big though.
		It&apos;ll make a suitable base of operations.
		I&apos;m moving down here, for the time being.
		After dumping off everything at the surface, I brought with me one locked chest, one snow block, one dirt node (which I jacked from my mushroom farm), three torches (I also left two in the cavern, so I&apos;ll have five down there), my stone pick, my bronze pick, and my remaining three bronze ingots.
		Everything else, I&apos;m leaving at the surface.
		By the time I get down there, I&apos;ll have stacks and stacks of pine needles, but I&apos;ll also have several pine saplings, which I can plant one of on the dirt I&apos;m bringing, and grow it next to the snow.
		I can&apos;t build a full pine farm down here, as the narrow mineshaft will only allow for one sapling at a time to get enough sunlight to grow, but that should be enough to keep me stocked up on pick handles, furnace fuel, and chests.
		I should be able to find more iron for chests as well, and get a furnace set up to smelt the metals, especially said iron for chests.
		I&apos;ll haul everything out later, once I&apos;m satisfied with exploring this huge cave.
		Hopefully, I can find some mese down here.
		I did find three mese in one of the caves I&apos;d previously visited, off in a hard-to-reach place over lava, and this massive cave is much deeper, so there should be some down here.
	</p>
	<p>
		I guess I&apos;m back to hunting mese.
		I&apos;d planned to just hunt minerals in general, but I can&apos;t even set up a full-fledged base of operations down here without cotton, so I need to get my railway built, and I need mese for that.
		I&apos;ll be setting up a makeshift base of operations, but it&apos;ll differ from a full-fledged base of operations in that I&apos;m not allowed to let myself die down here.
		If I die down here, I&apos;ll spawn back at the surface.
		Without having built my stack back up on the way out, I won&apos;t be able to safely get down again.
		If I get low on health, I&apos;ll need to build my way back to the top, die, then dig my way back down again.
		I need to be careful not to get hurt much so I won&apos;t have to do that often.
		If I had a bed down here though, I could spawn at the bottom, where I could build my way back up when and only when I was done down here.
	</p>
</section>
END
);
